// pages/myOrders/myOrders.js
var app = new getApp();
import Http from '../../utils/http.js';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    activeName:"",
    orderList:[],
    loading:false
  },
  onShareAppMessage() {
    app.globalFn.onShareAppMessage()
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      ...(options)
    })
    this.getOrderList()
  },
  //获取订单列表
  getOrderList(){
    wx.showLoading({
      title: '加载中',
      mask: true
    })
    this.setData({
      loading:true
    })
    Http.Request('GET', `/api/customer/order/getOrderList/v1?orderState=${this.data.activeName}`).then(res=>{
      this.setData({
        orderList:res,
        loading:false
      })
      wx.hideLoading();
    }).catch(err=>{
      wx.hideLoading();
      app.globalFn.reLoad(this.getOrderList, err)
    })
  },
  activeNameChange(e){
    this.setData({
      activeName:e.detail
    })
    this.getOrderList()
  }
})